package com.lu.pojo.oop.commoninterface.comparable;
import java.util.Arrays;

/**
 * @author luzhenfang
 * @date 2020 05 15
 * @description
 * Comparator 和 Comparable 接口使用
 */


public class TestComparable {
    public static void main(String[] args) {
        Student s1 = new Student("小明", 82);
        Student s2 = new Student("小华", 90);
        int result = s1.compareTo(s2);
        switch (result){
            case 0:
                System.out.println(s1.getName()+"和"+s2.getName()+"成绩一样好！");
                break;
            case 1:
                System.out.println(s1.getName()+"比"+s2.getName()+"成绩好！");
                break;
            case -1:
                System.out.println(s1.getName()+"没"+s2.getName()+"成绩好！");
                break;
            default:
                System.out.println("我也看不出什么猫腻！");
                break;
        }
        Student[] student = new Student[2];
        student[0]=s2;
        student[1]=s1;
        Arrays.sort(student,new ScoreCompartor());

        System.out.println(Arrays.toString(student));

    }
}
